home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / AOCE Sample Code / Standard Catalog Package / DTS AddressOMatic / Src / AOMDecorateDisplay.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-23  |  5.8 KB  |  214 lines  |  [TEXT/KAHL]

  1. /*                                AOMDecorateDisplay.c                            */
  2. /*
  3.  * AddressOMatic Sample
  4.  * AOMCreatePanels.c
  5.  * Copyright © 1993 Apple Computer Inc. All rights reserved.
  6.  * The functions in this module organize the visual appearance of the
  7.  * AOM panel. You should note the following:
  8.  *
  9.  * Radio buttons
  10.  *        The four radio buttons are always aligned to the top-left of the
  11.  *        display. (In Right-to-Left systems, they should be positioned at
  12.  *        the top-right; but not right now.)
  13.  * Action buttons
  14.  *        The "to" button is at the bottom right, with the "cc" button next
  15.  *        to it. The "done" button is at the bottom left.
  16.  * SDP Panel
  17.  *        The SDP Panels are "elastic" -- the top-left is fixed in position
  18.  *        while the bottom-right is fixed with respect to the bottom-right
  19.  *        of the window.
  20.  * Spinner
  21.  *        The spinner is fixed with respect to the top-right corner.
  22.  * Panel Label
  23.  *        The panel label is centered over the SDP Panel area. 
  24.  */
  25. #include "AddressOMaticPrivate.h"
  26.  
  27. void                            _AOMDecorateButton(
  28.         register AddressOMaticPtr    aomPtr,
  29.         ControlHandle                theControl,
  30.         AOMItemIndex                index
  31.     );
  32.  
  33. /*
  34.  * _AOMDecorateDisplay is a private function that is called when the window
  35.  * is created, moved, or when it changes size. It computes all item rectangles.
  36.  */ 
  37. void
  38. _AOMDecorateDisplay(
  39.         register AddressOMaticPtr    aomPtr
  40.     )
  41. {
  42.         short                        i;
  43. #ifdef ENABLE_TYPEIN
  44.         Str255                        work;
  45. #endif
  46.  
  47.         EraseRect(&BOUNDS);
  48.         ValidRect(&BOUNDS);
  49.         /*
  50.          * Inset the user specification to make room for the big fat
  51.          * drop shadow.
  52.          */
  53.         INTERIOR = BOUNDS;
  54.         INTERIOR.right    -= kAOMDropShadowWidth;
  55.         INTERIOR.bottom    -= kAOMDropShadowWidth;
  56.         /*
  57.          * Position the radio buttons
  58.          */
  59.         SetRect(
  60.             &RECT(kAOMPDButtonItem),
  61.             INTERIOR.left    + kAOMRadioButtonLeft,
  62.             INTERIOR.top    + kAOMRadioButtonTop,
  63.             INTERIOR.left    + kAOMRadioButtonLeft + kAOMRadioButtonSize,
  64.             INTERIOR.top    + kAOMRadioButtonTop + kAOMRadioButtonSize
  65.         );
  66.         InvalRect(&RECT(kAOMPDButtonItem));
  67.         for (i = kAOMDirButtonItem; i <= kAOMLastRadio; i++) {
  68.             RECT(i) = RECT(i - 1);
  69.             OffsetRect(&RECT(i), 0, kAOMRadioButtonVOffset);
  70.             InvalRect(&RECT(i));
  71.         }
  72.         /*
  73.          * Position the SDP Panel area
  74.          */
  75.         SetRect(
  76.             &PANEL,
  77.             INTERIOR.left    + kAOMPanelLeftInset,
  78.             INTERIOR.top    + kAOMPanelTopInset,
  79.             INTERIOR.right    - kAOMPanelRightInset,
  80.             INTERIOR.bottom    - kAOMPanelBottomInset
  81.         );
  82.         /*
  83.          * Position the components of the Type-In Panel.
  84.          */
  85. #ifdef ENABLE_TYPEIN
  86.         SetRect(
  87.             &RECT(kAOMTypeInAddrLabelItem),
  88.             PANEL.left,
  89.             INTERIOR.top + kAOMTypeInAddressLabelTop,
  90.             PANEL.right,
  91.             INTERIOR.top + kAOMTypeInAddressLabelTop + kAOMLabelFontHeight
  92.         );
  93.         GetIndString(work, AOM.stringsResID, kAOMTypeInDirLabelString);
  94.         _AOMSetFont(aomPtr, kAOMLabelFontStyle);
  95.         SetRect(
  96.             &RECT(kAOMTypeInAddressItem),
  97.             PANEL.left,
  98.             INTERIOR.top + kAOMTypeInAddressTop,
  99.             PANEL.right,
  100.             INTERIOR.top + kAOMTypeInAddressBottom
  101.         );
  102.         /*
  103.          * See the note in AOMTypeInManager: we keep a separate popup title
  104.          * so the panel looks correct.
  105.          */
  106.         SetRect(
  107.             &RECT(kAOMTypeInDirLabelItem),
  108.             PANEL.left,
  109.             INTERIOR.top + kAOMTypeInDirectoryLabelTop,
  110.             PANEL.left + StringWidth(work),
  111.             INTERIOR.top + kAOMTypeInDirectoryLabelTop + kAOMLabelFontHeight
  112.         );
  113.         SetRect(
  114.             &RECT(kAOMTypeInDirectoryItem),
  115.             RECT(kAOMTypeInDirLabelItem).right + CharWidth('n'),
  116.             INTERIOR.top + kAOMTypeInPopupTop,
  117.             PANEL.right,
  118.             INTERIOR.top + kAOMTypeInPopupTop + kAOMTypeInPopupHeight
  119.         );
  120. #endif
  121.         /*
  122.          * Extend the SDP Panel area so there is space for the
  123.          * Focus rectangle (which extends beyond the panel area)
  124.          */
  125.         EXTERIOR = PANEL;
  126.         InsetRect(&EXTERIOR, -4, -4);
  127.         /*
  128.          * Position the action buttons -- after the SDP Panel
  129.          */
  130.         SetRect(
  131.             &RECT(kAOMDoneButtonItem),
  132.             RECT(kAOMSDPPanelItem).left,
  133.             INTERIOR.bottom - (kAOMButtonBottomInset + kAOMButtonHeight),
  134.             RECT(kAOMSDPPanelItem).left + kAOMDoneButtonWidth,
  135.             INTERIOR.bottom - kAOMButtonBottomInset
  136.         );
  137.         SetRect(
  138.             &RECT(kAOMToButtonItem),
  139.             RECT(kAOMSDPPanelItem).right - kAOMToButtonWidth,
  140.             RECT(kAOMDoneButtonItem).top,
  141.             RECT(kAOMSDPPanelItem).right,
  142.             RECT(kAOMDoneButtonItem).bottom
  143.         );
  144.         RECT(kAOMCCButtonItem) = RECT(kAOMToButtonItem);
  145.         OffsetRect(
  146.             &RECT(kAOMCCButtonItem),
  147.             - (kAOMCCButtonWidth + kAOMCCButtonGap),
  148.             0
  149.         );
  150.         RECT(kAOMCCButtonItem).right =
  151.             RECT(kAOMCCButtonItem).left + kAOMCCButtonWidth;
  152.         /*
  153.          * Position the spinner
  154.          */
  155.         SetRect(
  156.             &RECT(kAOMSpinnerItem),
  157.             INTERIOR.right - kAOMSpinnerRightInset,
  158.             INTERIOR.top + kAOMSpinnerTopInset,
  159.             INTERIOR.right - kAOMSpinnerRightInset + kAOMSpinnerSize,
  160.             INTERIOR.top + kAOMSpinnerTopInset + kAOMSpinnerSize
  161.         );
  162.         /*
  163.          * Position the panel label
  164.          */
  165.         SetRect(
  166.             &TITLE,
  167.             RECT(kAOMSDPPanelItem).left,
  168.             INTERIOR.top + kAOMPanelLabelTop,
  169.             RECT(kAOMSpinnerItem).left - 1,
  170.             INTERIOR.top + kAOMPanelLabelTop + kAOMPanelLabelHeight
  171.         );
  172.         /*
  173.          * Now, reposition the window content.
  174.          */
  175.         _AOMDecorateButton(aomPtr,    AOM.doneButton,    kAOMDoneButtonItem);
  176.         _AOMDecorateButton(aomPtr,    AOM.ccButton,    kAOMCCButtonItem);
  177.         _AOMDecorateButton(aomPtr,    AOM.toButton,    kAOMToButtonItem);
  178.         /*
  179.          * Reposition the SDP stuff
  180.          */
  181.         if (AOM.pdPanel != NULL)
  182.             _AOMPanelAdjust(aomPtr, AOM.pdPanel);
  183.         if (AOM.browsePanel != NULL)
  184.             _AOMPanelAdjust(aomPtr, AOM.browsePanel);
  185.         if (AOM.findPanel != NULL)
  186.             _AOMFindAdjust(aomPtr);
  187. #ifdef ENABLE_TYPEIN
  188.         _AOMTypeInAdjust(aomPtr);
  189. #endif
  190. }
  191.  
  192. /*
  193.  * Position one of the buttons.
  194.  */
  195. void
  196. _AOMDecorateButton(
  197.         register AddressOMaticPtr    aomPtr,
  198.         ControlHandle                theControl,
  199.         AOMItemIndex                index
  200.     )
  201. {
  202.         Rect                        viewRect;
  203.         
  204.         viewRect = RECT(index);
  205.         if (theControl != NULL
  206.          && EqualRect(&(**theControl).contrlRect, &viewRect) == FALSE) {
  207.             HideControl(theControl);
  208.             MoveControl(theControl, viewRect.left, viewRect.top);
  209.             SizeControl(theControl, width(viewRect), height(viewRect));
  210.             if (AOM.isVisible)
  211.                 ShowControl(theControl);
  212.         }            
  213. }
  214.